home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DELPHI.SWG / 0003_Smooth Paint Blotter like SK Windows.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  6.9 KB  |  343 lines

  1. unit Blotter3;
  2.  
  3. interface
  4.  
  5. uses
  6.     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.     Forms, Dialogs, ExtCtrls;
  8.  
  9. type
  10.     TmeiSmoothBlotter = class(TPanel)
  11.  
  12.     private
  13.         { Private declarations }
  14.  
  15.     protected
  16.         { Protected declarations }
  17.         procedure Paint; override;
  18.  
  19.     public
  20.         { Public declarations }
  21.         constructor Create(AOwner: TComponent); override;
  22.  
  23.     published
  24.         { Published declarations }
  25. {        property BorderWidth default 8;
  26.         property Color default clGreen;}
  27.  
  28.  end;
  29.  
  30. procedure Register;
  31.  
  32. implementation
  33.  
  34. constructor TmeiSmoothBlotter.Create(AOwner: TComponent);
  35.     Begin
  36.     Inherited Create(Aowner);
  37.     if (csDesigning in ComponentState) then
  38.     begin
  39.         BorderWidth := 8;
  40.         Color := clGreen;
  41.         Align := alClient;
  42.     end;
  43.     End;
  44.  
  45. procedure TmeiSmoothBlotter.Paint;
  46. var
  47.     bmpBlotter : TBitMap;
  48.  
  49. Begin
  50.  
  51. bmpBlotter := TBitMap.Create;
  52.  
  53. try
  54.  
  55. {size the bitmap}
  56.     With Canvas do
  57.     begin
  58.         bmpBlotter.Height := Height;
  59.         bmpBlotter.Width := Width;
  60.     end;
  61.  
  62. {draw on the bitmap}
  63.     With bmpBlotter.Canvas Do
  64.         Begin
  65.  
  66.         Brush.Color := Color; {BlotterColor;}
  67.         Rectangle(0,0,Width,Height);
  68.  
  69.     {**************************************************}
  70.         {draw vertical lines on left side of form}
  71.         Pen.Color := clBlack;
  72.         Moveto(0,0);                {column,row}
  73.         Lineto(0,Height);
  74.  
  75.         Pen.Color := clSilver;
  76.         Moveto(0+1,0);                {column,row}
  77.         Lineto(0+1,Height);
  78.  
  79.         Pen.Color := clBlack;
  80.         Moveto(0+4,0);                {column,row}
  81.         Lineto(0+4,Height);
  82.  
  83.         {draw vertical line on right side of form}
  84.         Pen.Color := clSilver;
  85.         Moveto(Width-4,0);
  86.         Lineto(Width-4,Height);
  87.  
  88.         Pen.Color := clBlack;
  89.         Moveto(Width-1,0);
  90.         Lineto(Width-1,Height);
  91.  
  92.         {draw horizontal line on top side of form}
  93.         Pen.Color := clBlack;
  94.         Moveto(0,0);
  95.         Lineto(Width,0);
  96.  
  97.         Pen.Color := clSilver;
  98.         Moveto(0,0+1);
  99.         Lineto(Width,0+1);
  100.  
  101.         Pen.Color := clBlack;
  102.         Moveto(0,0+4);
  103.         Lineto(Width,0+4);
  104.  
  105.         {draw horizontal line on bottom side of form}
  106.         Pen.Color := clSilver;
  107.         Moveto(0,Height-4);
  108.         Lineto(Width,Height-4);
  109.  
  110.         Pen.Color := clBlack;
  111.         Moveto(0,Height-1);
  112.         Lineto(Width,Height-1);
  113.  
  114.         {***************************************************}
  115.         {draw blotter outer corners}
  116.         Pen.Color := clYellow;
  117.         {Upper Left vertical and horizontal}
  118.         MoveTo(0+1,0+1);
  119.         LineTo(0+1,15);
  120.         Moveto(0+1,0+1);
  121.         LineTo(15,0+1);
  122.         {Lower Left vertical only }
  123.         MoveTo(0+1,Height-1);
  124.         LineTo(0+1,Height-16);
  125.         {Lower Right}
  126.         Pen.Color := clBlack;
  127.         MoveTo(Width-2,Height-1);
  128.         LineTo(Width-15,Height-1);
  129.         MoveTo(Width-1,Height-1);
  130.         LineTo(Width-1,Height-15);
  131.         Pen.Color := clYellow;
  132.         MoveTo(Width-15,Height-1);
  133.         LineTo(Width-16,Height-1);
  134.         MoveTo(Width-1,Height-15);
  135.         LineTo(Width-1,Height-16);
  136.         {Upper Right, horizontal only}
  137.         MoveTo(Width-15, 1);
  138.         LineTo(Width-1, 1);
  139.  
  140.     {************************************************}
  141.         {draw blotter inner corners}
  142.         Pen.Color := clBlack;
  143.         Brush.Color := clBlack;
  144.         {Upper Left}
  145.         MoveTo(0+5,0+5);
  146.         LineTo(0+5,6+6);
  147.         Moveto(0+5,0+5);
  148.         LineTo(6+6,0+5);
  149.  
  150.         {Lower Left}
  151.         MoveTo(0+5,Height-5);
  152.         LineTo(0+5,(Height-5)-7);    {draw vert}
  153.         Moveto(0+5,Height-5);
  154.         LineTo(12,Height-5);    {draw horiz}
  155.  
  156.         Pen.Color := clYellow;
  157.         MoveTo(0+6,Height-5);
  158.         LineTo(11,Height-5);
  159.         Pen.Color := clBlack;
  160.  
  161.             {lower right}
  162.         Pen.Color := clYellow;
  163.         MoveTo(Width-5,Height-5);
  164.         LineTo(Width-5,Height-12);
  165.         MoveTo(Width-5,Height-5);
  166.         LineTo(Width-12,Height-5);
  167.  
  168.         {Upper Right}
  169.         Pen.Color := clBlack;
  170.         MoveTo(Width-11,5);
  171.         LineTo(Width-5,5);
  172.         Pen.Color := clYellow;
  173.         MoveTo(Width-5,5);
  174.         LineTo(Width-5,13);
  175.  
  176.     {************************************************}
  177.         {draw the staircase pixels}
  178.         Pen.Color := clBlack;
  179.  
  180.         {upper left}
  181.                 {lower pixels}
  182.         MoveTo(0+1,15);
  183.         LineTo(0+4,12);
  184.  
  185.         Moveto(2,Height-13);
  186.         LineTo(3,Height-12);
  187.         Moveto(4,Height-11);
  188.         LineTo(4,Height-11);
  189.  
  190.                 {upper pixels}
  191.         MoveTo(15,0+1);
  192.         LineTo(12,0+4);
  193.  
  194.  
  195.         {lower left}
  196.                 {upper pixels}
  197.         Pen.Color := clYellow;
  198.         Moveto(2,Height-14);
  199.         LineTo(5,Height-11);
  200.  
  201.         Pen.Color := clBlack;
  202.         MoveTo(11,Height-5);
  203.         LineTo(15,Height-1);
  204.  
  205.         {lower right}
  206.         Pen.Color := clYellow;
  207.         MoveTo(Width-15,Height-1);
  208.         LineTo(Width-10,Height-6);
  209.         MoveTo(Width-1,Height-15);
  210.         LineTo(Width-6,Height-10);
  211.  
  212.         { Upper Right}
  213.         Pen.Color := clBlack;
  214.         MoveTo(Width-1,16);
  215.         LineTo(Width-5,12);
  216.  
  217.         MoveTo(Width-14,2);
  218.         LineTo(Width-12,4);
  219.  
  220.     {****************************************************}
  221.         {fill in "brass" areas for corners}
  222.         Brush.Color := clOlive;
  223.         Pen.Color := clOlive;
  224.  
  225.         {upper left}
  226.         {fill in large areas}
  227.         Rectangle(2,2,5,12);
  228.         Rectangle(2,2,12,5);
  229.  
  230.         {fill in upper pixels}
  231.         Moveto(12,2);
  232.         LineTo(14,2);
  233.         Moveto(12,3);
  234.         LineTo(13,3);
  235.         {fill in lower pixels}
  236.         MoveTo(2,12);
  237.         LineTo(2,14);
  238.         MoveTo(3,12);
  239.         LineTo(3,13);
  240.  
  241.     {------------------------}
  242.         {lower left}
  243.         {fill in large areas}
  244.         Rectangle(2,Height-1,12,Height-4);
  245.         Rectangle(2,Height-2,5,Height-11);
  246.  
  247.         {fill in upper pixels}
  248.         Moveto(2,Height-13);
  249.         LineTo(3,Height-12);
  250.         Moveto(2,Height-12);
  251.         LineTo(4,Height-12);
  252.         Moveto(4,Height-11);
  253.         LineTo(4,Height-11);
  254.         {fill in lower pixels}
  255.         MoveTo(12,Height-3);
  256.         LineTo(13,Height-2);
  257.         MoveTo(14,Height-1);
  258.         LineTo(14,Height-1);
  259.         MoveTo(12,Height-2);
  260.         LineTo(14,Height-2);
  261.  
  262.         {-----------------------}
  263.             {lower right}
  264.  
  265.             {fill in large areas}
  266.         Rectangle(Width-1,Height-1,Width-11,
  267.                                                                                         Height-4);
  268.         Rectangle(Width-1,Height-1,Width-4,Height-11);
  269.  
  270.         {fill in upper pixels}
  271.         MoveTo(Width-3,Height-12);
  272.         LineTo(Width-1,Height-12);
  273.         MoveTo(Width-2,Height-13);
  274.         LineTo(Width-1,Height-13);
  275.  
  276.         {fill in lower pixels}
  277.         MoveTo(Width-12,Height-3);
  278.         LineTo(Width-12,Height-1);
  279.         MoveTo(Width-13,Height-2);
  280.         LineTo(Width-13,Height-1);
  281.  
  282.         {-----------------------}
  283.             {upper right}
  284.  
  285.             {fill in large areas}
  286.         Rectangle(Width-11,2,Width-1,5);
  287.         Rectangle(Width-1,13,Width-4,2);
  288.  
  289.             {fill in upper pixels}
  290.             MoveTo(Width-12,2);
  291.             LineTo(Width-12,4);
  292.             MoveTo(Width-13,2);
  293.             LineTo(Width-13,1);
  294.  
  295.             {fill in lower pixels}
  296.             MoveTo(Width-2,13);
  297.             LineTo(Width-4,13);
  298.             MoveTo(Width-2,14);
  299.             LineTo(Width-1,14);
  300.  
  301.     {***************************************************}
  302.         {cleanup corner pixels}
  303.         Pen.Color := clBlack;
  304.         Moveto(0,0);
  305.         LineTo(0,10);
  306.  
  307.         {Lower Left}
  308.         MoveTo(0,Height-1);
  309.         LineTo(13,Height-1);
  310.         MoveTo(0,Height-1);
  311.         LineTo(0,Height-14);
  312.  
  313.             {Upper Right}
  314.         Moveto(Width-1,0);
  315.         LineTo(Width-14,0);
  316.         Moveto(Width-1,0);
  317.         LineTo(Width-1,13);
  318.  
  319.         {Lower Right}
  320.         MoveTo(Width-1,Height-1);
  321.         LineTo(Width-14,Height-1);
  322.         MoveTo(Width-1,Height-1);
  323.         LineTo(Width-1,Height-14);
  324.  
  325.         end;
  326.  
  327.         {copy the bitmap image to the panel's canvas}
  328.  
  329.         Canvas.Draw(0,0,bmpBlotter);
  330.  
  331. finally
  332.     bmpBlotter.Free;
  333. end;
  334.  
  335. end;
  336.  
  337. procedure Register;
  338. begin
  339.     RegisterComponents('PRIME', [TmeiSmoothBlotter]);
  340. end;
  341.  
  342. end.
  343.